<?php 
session_cache_expire(999999999);
if(!isset($_SESSION)) 
{ 
	session_start(); 
}
$_SESSION['mang']=array();
$_SESSION['mang'][]="";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Print</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="../../js/jquery.price_format.1.7.js"></script>
<script type="text/javascript" src="../../js/jquery.price_format.1.7.min.js"></script>
<link rel="stylesheet" type="text/css" href="admin/css/jsDatePick_ltr.min.css" />
<script type="text/javascript" src="../../admin/css/jsDatePick.min.1.3.js"></script>
<link	href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../../js/jquery.autocomplete.css" />
<script type="text/javascript" src="../../js/jquery.autocomplete.js"></script>
<script language="javascript" src="../../js/cal2.js"></script>
<script type="text/javascript">
window.onload = function(){
	loadCal();
}

function loadCal(){
	var sl=document.getElementById("songay1").value;
	for(i=0;i<Number(sl);i++){
		addCalendar("Calendar"+i, "xtxttimetran"+i, "xtxttimetran"+i, "fname");
		setWidth(90, 1, 15, 1);
		setFormat("yyyy-mm-dd");
	}
	
}

function add1(){
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp2=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp2.onreadystatechange=function(){
										  if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
										    	document.getElementById("showinput1").innerHTML=xmlhttp2.responseText;
										    	loadCal();
										  }
	}
	xmlhttp2.open("POST","add_cal.php?",true);
	xmlhttp2.send();
}

function btclick(giatri,vitri){
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp2=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp2.onreadystatechange=function(){
										  if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
										    	document.getElementById("songay1").innerHTML=xmlhttp2.responseText;
										  }
	}
	xmlhttp2.open("POST","change_cal.php?vitri="+vitri+"&giatri="+giatri,true);
	xmlhttp2.send();
	//alert(vitri+" -- "+giatri);
}
</script>
</head>
<body>
<form name="fname">

<input type="button" value="Add" onclick="add1()" />
<div id="showinput1">
<?php 
	$sl=count($_SESSION['mang']);
	if($sl>0){
		for($i=0;$i<$sl;$i++){
		?>
			<input onclick="javascript:showCal('<?php echo "Calendar".$i;?>')" type="text" id="<?php echo 'xtxttimetran'.$i;?>" name="<?php echo 'xtxttimetran'.$i;?>" value="<?=$_SESSION['mang'][$i]?>" size=20 onfocus="btclick(this.value,<?=$i?>);" />
			 <small><a href="javascript:showCal('<?php echo "Calendar".$i;?>')">Select Date</a></small>
		<?php 
		}
	}
?>
<input type="hidden" id="songay1" value="<?=count($_SESSION['mang'])?>" />
</div>
</form>
</body>
</html>